﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QLKS
{
    public partial class FrmCheckRoom : Form
    {
        public FrmCheckRoom()
        {
            InitializeComponent();
        }

        private void tabControlCheckRoom_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (tabControlCheckRoom.SelectedIndex == 0)
                {
                    if (tabControlCheckRoom.SelectedIndex == 0)
                    {
                        FrmCheckRoom1 frm1 = new FrmCheckRoom1 { TopLevel = false, Parent = tabControlCheckRoom.TabPages[tabControlCheckRoom.SelectedIndex], Dock = DockStyle.Fill, FormBorderStyle = FormBorderStyle.None };
                        frm1.Show();
                        tabControlCheckRoom.SelectedTab = tabControlCheckRoom.TabPages[tabControlCheckRoom.SelectedIndex];
                    }
                }
                else if (tabControlCheckRoom.SelectedIndex == 1)
                {
                    FrmCheckRoom2 frm2 = new FrmCheckRoom2 { TopLevel = false, Parent = tabControlCheckRoom.TabPages[tabControlCheckRoom.SelectedIndex], Dock = DockStyle.Fill, FormBorderStyle = FormBorderStyle.None };
                    frm2.Show();
                    tabControlCheckRoom.SelectedTab = tabControlCheckRoom.TabPages[tabControlCheckRoom.SelectedIndex];
                }
            }
            catch (Exception x)
            {
                MessageBox.Show(string.Format("Lỗi: {0}", x.Message), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void FrmCheckRoom_Load(object sender, EventArgs e)
        {
            try
            {
                if (tabControlCheckRoom.SelectedIndex == 0)
                {
                    FrmCheckRoom1 frm1 = new FrmCheckRoom1 { TopLevel = false, Parent = tabControlCheckRoom.TabPages[tabControlCheckRoom.SelectedIndex], Dock = DockStyle.Fill, FormBorderStyle = FormBorderStyle.None };
                    frm1.Show();
                    tabControlCheckRoom.SelectedTab = tabControlCheckRoom.TabPages[tabControlCheckRoom.SelectedIndex];
                }
            }
            catch (Exception)
            {

                throw;
            }
        }

        public void showRoom(int ngay, int thang, int nam, string maphong)
        {
            foreach (Form f in MdiChildren)
            {
                if (f is FrmCheckIn)
                {
                    f.Activate();
                    return;
                }
            }
            FrmCheckIn obj = new FrmCheckIn(ngay,thang,nam,maphong);
            obj.MdiParent = ParentForm as Frm_Main;
            obj.Show();
        }
 
    }
}
